home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.n / switch.n < prev    next >
Text File  |  1995-07-25  |  7KB  |  131 lines

  1.  
  2.  
  3.  
  4.      sssswwwwiiiittttcccchhhh((((nnnn))))                   TTTTccccllll ((((7777....0000))))                   sssswwwwiiiittttcccchhhh((((nnnn))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           switch - Evaluate one of several  scripts,  depending  on  a
  12.           given value
  13.  
  14.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  15.           sssswwwwiiiittttcccchhhh ?_o_p_t_i_o_n_s? _s_t_r_i_n_g _p_a_t_t_e_r_n _b_o_d_y ?_p_a_t_t_e_r_n _b_o_d_y ...?
  16.           sssswwwwiiiittttcccchhhh ?_o_p_t_i_o_n_s? _s_t_r_i_n_g {_p_a_t_t_e_r_n _b_o_d_y ?_p_a_t_t_e_r_n _b_o_d_y ...?}
  17.      _________________________________________________________________
  18.  
  19.  
  20.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.           The sssswwwwiiiittttcccchhhh command matches its _s_t_r_i_n_g argument against  each
  22.           of  the  _p_a_t_t_e_r_n  arguments in order.  As soon as it finds a
  23.           _p_a_t_t_e_r_n that matches _s_t_r_i_n_g it evaluates the following  _b_o_d_y
  24.           argument  by  passing  it recursively to the Tcl interpreter
  25.           and returns the result of  that  evaluation.   If  the  last
  26.           _p_a_t_t_e_r_n argument is ddddeeeeffffaaaauuuulllltttt then it matches anything.  If no
  27.           _p_a_t_t_e_r_n argument matches _s_t_r_i_n_g and  no  default  is  given,
  28.           then the sssswwwwiiiittttcccchhhh command returns an empty string.
  29.  
  30.           If the initial arguments to sssswwwwiiiittttcccchhhh start with  ----  then  they
  31.           are treated as options.  The following options are currently
  32.           supported:
  33.  
  34.           ----eeeexxxxaaaacccctttt    Use exact matching  when  comparing  _s_t_r_i_n_g  to  a
  35.                     pattern.  This is the default.
  36.  
  37.           ----gggglllloooobbbb     When matching _s_t_r_i_n_g to the  patterns,  use  glob-
  38.                     style  matching  (i.e.  the same as implemented by
  39.                     the ssssttttrrrriiiinnnngggg mmmmaaaattttcccchhhh command).
  40.  
  41.           ----rrrreeeeggggeeeexxxxpppp   When matching _s_t_r_i_n_g to the patterns, use  regular
  42.                     expression  matching (i.e. the same as implemented
  43.                     by the rrrreeeeggggeeeexxxxpppp command).
  44.  
  45.           --------        Marks the end of options.  The argument  following
  46.                     this  one  will  be  treated  as _s_t_r_i_n_g even if it
  47.                     starts with a ----....
  48.  
  49.           Two  syntaxes  are  provided  for  the  _p_a_t_t_e_r_n   and   _b_o_d_y
  50.           arguments.   The  first uses a separate argument for each of
  51.           the patterns  and  commands;  this  form  is  convenient  if
  52.           substitutions  are  desired  on  some  of  the  patterns  or
  53.           commands.  The second form places all of  the  patterns  and
  54.           commands  together into a single argument; the argument must
  55.           have proper list structure, with the elements  of  the  list
  56.           being  the  patterns and commands.  The second form makes it
  57.           easy to construct  multi-line  switch  commands,  since  the
  58.           braces  around the whole list make it unnecessary to include
  59.           a backslash at the end of  each  line.   Since  the  _p_a_t_t_e_r_n
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/17/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      sssswwwwiiiittttcccchhhh((((nnnn))))                   TTTTccccllll ((((7777....0000))))                   sssswwwwiiiittttcccchhhh((((nnnn))))
  71.  
  72.  
  73.  
  74.           arguments  are  in  braces in the second form, no command or
  75.           variable substitutions are performed on  them;   this  makes
  76.           the  behavior  of  the  second form different than the first
  77.           form in some cases.
  78.  
  79.           If a _b_o_d_y is specified as ``----'' it means that the  _b_o_d_y  for
  80.           the  next  pattern  should also be used as the body for this
  81.           pattern (if the next pattern also has a body of  ``----''  then
  82.           the body after that is used, and so on).  This feature makes
  83.           it possible to share a single _b_o_d_y among several patterns.
  84.  
  85.           Below are some examples of sssswwwwiiiittttcccchhhh commands:
  86.  
  87.                sssswwwwiiiittttcccchhhh aaaabbbbcccc aaaa ---- bbbb {{{{ffffoooorrrrmmmmaaaatttt 1111}}}} aaaabbbbcccc {{{{ffffoooorrrrmmmmaaaatttt 2222}}}} ddddeeeeffffaaaauuuulllltttt {{{{ffffoooorrrrmmmmaaaatttt 3333}}}}
  88.           will return 2222,
  89.  
  90.                sssswwwwiiiittttcccchhhh ----rrrreeeeggggeeeexxxxpppp aaaaaaaaaaaabbbb {{{{
  91.                  ^^^^aaaa....****bbbb$$$$ ----
  92.                  bbbb {{{{ffffoooorrrrmmmmaaaatttt 1111}}}}
  93.                  aaaa**** {{{{ffffoooorrrrmmmmaaaatttt 2222}}}}
  94.                  ddddeeeeffffaaaauuuulllltttt {{{{ffffoooorrrrmmmmaaaatttt 3333}}}}
  95.                }}}}
  96.           will return 1111, and
  97.  
  98.                sssswwwwiiiittttcccchhhh xxxxyyyyzzzz {{{{
  99.                  aaaa
  100.                    ----
  101.                  bbbb
  102.                    {{{{ffffoooorrrrmmmmaaaatttt 1111}}}}
  103.                  aaaa****
  104.                    {{{{ffffoooorrrrmmmmaaaatttt 2222}}}}
  105.                  ddddeeeeffffaaaauuuulllltttt
  106.                    {{{{ffffoooorrrrmmmmaaaatttt 3333}}}}
  107.                }}}}
  108.           will return 3333.
  109.  
  110.  
  111.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  112.           switch, match, regular expression
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.      Page 2                                          (printed 7/17/95)
  127.  
  128.  
  129.  
  130.